package logic

import (
	"activity_srv/activity"
	"activity_srv/internal/svc"
	"activity_srv/model"
	"context"
	"go.uber.org/zap"
	"smart-health-platforms/pkg"

	"github.com/zeromicro/go-zero/core/logx"
)

type BargainHelpListLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewBargainHelpListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *BargainHelpListLogic {
	return &BargainHelpListLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

// 帮砍列表
func (l *BargainHelpListLogic) BargainHelpList(in *activity.BargainHelpListRequest) (*activity.BargainHelpListResponse, error) {
	var ba model.BargainHelp
	ba.BargainActivityId = int32(in.BargainId)
	list, err := ba.BargainHelpList()
	if err != nil {
		pkg.Error("失败", zap.Error(err))
		return nil, err
	}
	var baList []*activity.BargainHelpList
	for _, bargain := range list {
		baList = append(baList, &activity.BargainHelpList{
			BargainActivityId: int64(bargain.BargainActivityId),
			UserId:            int64(bargain.UserId),
			Price:             float32(bargain.Price),
		})
	}
	return &activity.BargainHelpListResponse{
		List: baList,
	}, nil
}
